import com.entity.Book;
import com.mapper.BookMapper;
import com.util.MybatiesUtil;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by webrx on 2017/6/15.
 */
public class Dom {
    @Test
    public void show() throws IOException {


       SqlSession s= new MybatiesUtil().getSession();
        BookMapper dao =s.getMapper(BookMapper.class);
       /* Book book=dao.queryById(4);*/

        //分页查询
      /* Map<String,Integer> map = new HashMap<String, Integer>();
       int start  =1;
       int pagesize =2;
       map.put("start",start*pagesize-pagesize);
       map.put("pagesize",pagesize);

       List<Book> book = dao.page(map);
       for (Book boo :book){
           System.out.println(boo.getName());
       }
*/
        RowBounds ro = new RowBounds(0,2);
      List<Book> books =dao.page02(ro);
      for(Book boo:books){
          System.out.println(boo.getName());
      }
       /*int nn= dao.deleteById(4);

        s.commit();
        System.out.println(nn);*/
     /* dao.delete();*/

       /*  Book book= dao.queryById(1);
        System.out.println(book.getName());*/

      /* int n =dao.deleteById(7);
        s.commit();
        System.out.println(n);*/

       /* Book book1 = new Book();
        book1.setName("外语");
        book1.setPrice(100);
        book1.setId(1);
        dao.update(book1);
        */

       /* Map<String,Object> map= new HashMap<String, Object>();
        map.put("name","");
        map.put("price",15);
        map.put("id",6);
        System.out.println(dao.save(map));*/

      /* Book book=dao.queryById(2);
        System.out.println(book.getName());*/
          s.commit();
    }
}
